package com.http;

import org.json.JSONObject;

import android.util.Log;

import com.android.ocean.util.net.NetConUtil;
import com.chat.adapter.JSONUtil;
import com.common.method.CommonData;
import com.common.method.ServerPath;

/**
 * 
 * @ClassName:ADListTask
 * @Description:TODO
 * @author zhuw
 * @date 2014-10-31 下午8:08:56
 */
public class ADListTask extends BaseTask {
	public ADListTask(NetCallBack callback) {
		super();
		this.callback = callback;
	}

	@Override
	protected Object doInBackground(Object... params) {
		try {
			JSONObject objParams = new JSONObject();
			objParams.put("catid", params[0] + "");
			objParams.put("order", "v");
			objParams.put("_lk",  "*");
			objParams.put("page", params[1] + "");
			objParams.put("pagesize", CommonData.DEFAULT_PAGE_SIZE);
			String jsonStr = NetConUtil.sendPostRequestByJson(
					ServerPath.AD_LIST_PATH,
					ServerPath.wrapperJson(objParams));
			JSONObject jr = new JSONObject(jsonStr);
			if (jr.getString("result").equals("1")) {
				flag = FLAG_SUCCESS;
				result = JSONUtil.parseAdList(jr.getJSONObject("data")
						.getJSONArray("lists"));
			} else {
				flag = FLAG_FAILED;
				result = jr.getJSONObject("data").getString("message");
			}

		} catch (Exception e) {
			trackError(e);
			flag = FLAG_FAILED;
			result = failedStr;
			Log.e(TAG, e.getMessage());
		}
		return result;
	}
}
